﻿using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace ldc_mvc_closing_hwk.Models.ApiModel
{
    public class ApiHelper
    {
        public static IActionResult ErrorDelete(string message = "", int code = 100)
        {
            return new OkObjectResult(new { Code = code, Message = message });
        }



        public static IActionResult Success(string message = "", int code = 0)
        {
            return new OkObjectResult(new { Code = code, Message = message});
        }

        public static IActionResult SuccessData(object data, string message = "", int code = 0)
        {
            return new OkObjectResult(new { Code = code, Message = message, Data = data });
        }

        public static IActionResult SuccessList<T>(List<T> data, int count, string message = "", int code = 0)
        {
            return new OkObjectResult(new { Code = code, Message = message, Data = data, Count = count });
        }

        public static IActionResult SuccessList<T>(List<T> data, string message = "", int code = 0)
        {
            return SuccessList(data, data.Count);
        }
    }
}
